package org.jeecg.modules.system.szty;

import com.xxl.job.core.biz.model.ReturnT;
import com.xxl.job.core.handler.annotation.XxlJob;
import lombok.extern.slf4j.Slf4j;
import org.jeecg.modules.system.service.ISysSyncDepartService;
import org.jeecg.modules.system.service.ISysSyncUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.io.IOException;
import java.security.InvalidKeyException;
import java.security.NoSuchAlgorithmException;

@Slf4j
@Component
public class SyncSztyUtil {

    @Autowired
    private ISysSyncDepartService sysSyncDepartService;

    @Autowired
    private ISysSyncUserService sysSyncUserService;

    @XxlJob("SyncStyJob")
    public ReturnT<String> executeSyncSzty(String params) throws IOException, NoSuchAlgorithmException, InvalidKeyException {

        //同步单位
        sysSyncDepartService.syncCorpData();
        //同步部门
        sysSyncDepartService.syncDepartData();
        //同步职务
        sysSyncDepartService.syncPositionData();
        //同步人员
        sysSyncUserService.syncUserData();

        return ReturnT.SUCCESS;
    }
}
